package com.ticket.controller.api;

import com.ticket.entity.Venue;
import com.ticket.entity.VenueSection;
import com.ticket.service.IVenueService;
import com.ticket.service.IVenueSectionService;
import com.ticket.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/venues")
public class VenueController {

    @Autowired
    private IVenueService venueService;
    
    @Autowired
    private IVenueSectionService venueSectionService;
    
    @GetMapping("/list")
    public Result<List<Venue>> getVenueList() {
        List<Venue> venues = venueService.list();
        return Result.success(venues);
    }
    
    @GetMapping("/{id}")
    public Result<Venue> getVenueById(@PathVariable Long id) {
        Venue venue = venueService.getById(id);
        if (venue == null) {
            return Result.error("场馆不存在");
        }
        return Result.success(venue);
    }
    
    @GetMapping("/{id}/sections")
    public Result<List<VenueSection>> getVenueSections(@PathVariable Long id) {
        List<VenueSection> sections = venueSectionService.getSectionsByVenueId(id);
        return Result.success(sections);
    }
} 